﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
public partial class download : System.Web.UI.Page
{
    AccessDAO dao = new AccessDAO();
    AccessConn con = new AccessConn();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            //aspNetPager控件分页
            string name = Request.QueryString["name"].ToString();
            string ss = "";
            if (name.Equals("下载中心"))
            {
                ss = "select count(*) from xzMessage,xzInfo  where xzMessage.tyId=xzInfo.typeId";
            }
            else
            {
                ss = "select count(*) from xzMessage,xzInfo where xzMessage.tyId=xzInfo.typeId and typeName='" + name+"'";

            }
            OleDbConnection conn = con.getConn();
            try
            {
                conn.Open();

                OleDbCommand comm = new OleDbCommand(ss, conn);
                this.AspNetPager1.AlwaysShow = true;
                this.AspNetPager1.PageSize = 5;
                this.AspNetPager1.RecordCount = (int)comm.ExecuteScalar();
                conn.Close();
            }
            catch
            { }
            show();
          

            string s2 = "select * from billInfo where id=1";
            DataSet ds2 = dao.getDs(s2);
            this.dlProdu.DataSource = ds2;
            this.dlProdu.DataBind();
        }
    }
    protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
    {
        this.AspNetPager1.CurrentPageIndex = e.NewPageIndex;

        show();
    }

    private void show()
    {
        DataSet ds = new DataSet();
        OleDbConnection conn = con.getConn();
        string name = Request.QueryString["name"].ToString();
        string ss = "";
        if (name.Equals("下载中心"))
        {
            ss = "select * from xzMessage,xzInfo  where xzMessage.tyId=xzInfo.typeId and xzMessage.tyId=xzInfo.typeId order by xzMessage.id desc";
        }
        else
        {
            ss = "select * from xzMessage,xzInfo where xzMessage.tyId=xzInfo.typeId and typeName='" + name + "' order by xzMessage.id desc";

        }

        try
        {
            conn.Open();
            OleDbDataAdapter da = new OleDbDataAdapter(ss, conn);
            da.Fill(ds, (this.AspNetPager1.CurrentPageIndex - 1) * this.AspNetPager1.PageSize, this.AspNetPager1.PageSize, "Page");
            this.xz.DataSource = ds.Tables["Page"];
            this.xz.DataBind();
            conn.Close();
        }
        catch
        { }
    }
}
